<template>
  <div class="film subpage" v-if="film">
    <my-head :title="$route.query.name"></my-head>
    <div class="film-box">
      <div class="film-top">
        <img :src="film.poster" alt="" class="poster" />
      </div>
      <div class="film-center">
        <div class="film1">
          <span class="film11"
            >{{ film.name
            }}<span class="film12">{{ film.filmType.name }}</span></span
          >
          <span class="film13">{{ film.grade }}分</span>
        </div>
        <div class="film2">{{ film.category }}</div>
        <div class="film3">{{ changeTime(film.premiereAt) }}上映</div>
        <div class="film4">{{ film.nation }} | {{ film.runtime }}分钟</div>
        <div class="film5">{{ film.synopsis }}</div>
      </div>
      <div class="film-nav">
        <span>演职人员</span>
        <div class="film-nav1">
          <div v-for="(l, i) in film.actors" :key="i">
            <img :src="l.avatarAddress" alt="" />
            <p>{{ l.name }}</p>
            <p>{{ l.role }}</p>
          </div>
        </div>
      </div>
    </div>
    <van-button class="checkpiao" @click="gotofilmcinemas">选座购票</van-button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      film: null,
      time: "",
    };
  },
  computed: {},
  methods: {
    //进来了就获取值  在链接中  查看请求头   film数据和请求头
    async getFilm() {
      let res = await this.$ajax.getMZdata(
        {
          filmId: this.$route.params.filmId,
        },
        {
          "X-Host": "mall.film-ticket.film.info",
        }
      );
      this.film = res.data.film;
    },
    gotofilmcinemas() {
      this.$router.push({
        name: "film-cinemas",
        params: {
          filmId: this.film.filmId,
        },
        query: {
          name: this.film.name,
        },
      });
    },
    changeTime(time) {
      return new Date(parseInt(time) * 1000)
        .toLocaleString()
        .replace(/:\d{1,2}$/, " ");
    },
  },
  mounted() {
    this.getFilm();
  },
};
</script>



<style lang="scss" scoped>
.film {
  background-color: #f4f4f4;
  padding-bottom: 50px;
  &-box {
    .film-top {
      width: 100%;
      height: 210px;
      overflow: hidden;
      position: relative;
      .poster {
        width: 100%;
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
      }
    }
    .film-center {
      height: 210px;
      width: 100%;
      padding: 20px;
      background-color: #fff;
      margin-bottom: 10px;
      .film1 {
        display: flex;
        justify-content: space-between;
      }
      .film11 {
        font-size: 24px;
        color: #191a1b;
      }
      .film12 {
        margin-left: 6px;
        background-color: #d2d6dc;
        font-size: 14px;
        padding: 1px;
        color: #fcfcf6;
        border-radius: 20%;
      }
      .film13 {
        color: #ffba38;
        font-size: 26px;
        margin-left: 80px;
      }
      .film2 {
        display: block;
        margin: 3px 0px;
        font-size: 13px;
        color: #797d82;
      }
      .film3 {
        display: block;
        margin: 3px 0px;
        font-size: 13px;
        color: #797d82;
      }
      .film4 {
        display: block;
        margin: 3px 0px;
        font-size: 13px;
        color: #797d82;
      }
      .film5 {
        height: 80px;
        width: 100%;
        font-size: 13px;
        color: #797d82;
        overflow: hidden;
      }
    }
    .film-nav {
      height: 170px;
      width: 100%;
      background-color: #fff;
      .film-nav1 {
        display: flex;
        width: 100%;
        overflow: auto;
        text-align: center;
        div {
          margin: 0px 5px;
        }

        p:nth-child(1) {
          padding-top: 10px;
          font-size: 12px;
          color: #191a1b;
          width: 85px;
          height: 18px;
          display: block;
          overflow: hidden;
          -o-text-overflow: ellipsis;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        p:nth-child(2) {
          font-size: 10px;
          color: #797d82;
        }
        span {
          font-size: 16px;
          text-align: left;
          color: #191a1b;
        }
        img {
          width: 87px;
          height: 118px;
        }
      }
    }
  }
  .checkpiao {
    position: fixed;
    bottom: 0;
    left: 0;
    height: 49px;
    width: 100%;
    text-align: center;
    background-color: #ff5f16;
    color: #fff;
    font-size: 16px;
    line-height: 49px;
  }
}
</style>